weld SvxMeasurePage

Change-Id: I08f177d74aff278c62f76e32a1401ff24f249c57
Reviewed-on: https://gerrit.libreoffice.org/60589
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/inc/measure.hxx b/cui/source/inc/measure.hxx
index 2a9fb17..a9af5c5 100644
--- a/cui/source/inc/measure.hxx
+++ b/cui/source/inc/measure.hxx
@@ -33,24 +33,6 @@
private:
    static const sal_uInt16 pRanges[];

    VclPtr<MetricField>         m_pMtrFldLineDist;
    VclPtr<MetricField>         m_pMtrFldHelplineOverhang;
    VclPtr<MetricField>         m_pMtrFldHelplineDist;
    VclPtr<MetricField>         m_pMtrFldHelpline1Len;
    VclPtr<MetricField>         m_pMtrFldHelpline2Len;
    VclPtr<TriStateBox>         m_pTsbBelowRefEdge;
    VclPtr<MetricField>         m_pMtrFldDecimalPlaces;

    VclPtr<SvxRectCtl>          m_pCtlPosition;
    VclPtr<TriStateBox>         m_pTsbAutoPosV;
    VclPtr<TriStateBox>         m_pTsbAutoPosH;
    VclPtr<TriStateBox>         m_pTsbShowUnit;
    VclPtr<ListBox>             m_pLbUnit;
    VclPtr<TriStateBox>         m_pTsbParallel;
    VclPtr<FixedText>           m_pFtAutomatic;

    VclPtr<SvxXMeasurePreview>  m_pCtlPreview;

    const SfxItemSet&   rOutAttrs;
    SfxItemSet          aAttrSet;
    const SdrView*      pView;
@@ -58,17 +40,36 @@

    bool            bPositionModified;

    RectCtl m_aCtlPosition;
    SvxXMeasurePreview  m_aCtlPreview;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrFldLineDist;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrFldHelplineOverhang;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrFldHelplineDist;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrFldHelpline1Len;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrFldHelpline2Len;
    std::unique_ptr<weld::CheckButton> m_xTsbBelowRefEdge;
    std::unique_ptr<weld::SpinButton> m_xMtrFldDecimalPlaces;
    std::unique_ptr<weld::CheckButton> m_xTsbAutoPosV;
    std::unique_ptr<weld::CheckButton> m_xTsbAutoPosH;
    std::unique_ptr<weld::CheckButton> m_xTsbShowUnit;
    std::unique_ptr<weld::ComboBox> m_xLbUnit;
    std::unique_ptr<weld::CheckButton> m_xTsbParallel;
    std::unique_ptr<weld::Label> m_xFtAutomatic;
    std::unique_ptr<weld::CustomWeld> m_xCtlPosition;
    std::unique_ptr<weld::CustomWeld> m_xCtlPreview;

    void                FillUnitLB();

    DECL_LINK( ClickAutoPosHdl_Impl, Button*, void );
    DECL_LINK( ChangeAttrEditHdl_Impl, Edit&, void );
    DECL_LINK( ChangeAttrListBoxHdl_Impl, ListBox&, void );
    DECL_LINK( ChangeAttrClickHdl_Impl, Button*, void );
    DECL_LINK(ClickAutoPosHdl_Impl, weld::ToggleButton&, void);
    DECL_LINK(ChangeAttrEditHdl_Impl, weld::MetricSpinButton&, void);
    DECL_LINK(ChangeAttrSpinHdl_Impl, weld::SpinButton&, void);
    DECL_LINK(ChangeAttrListBoxHdl_Impl, weld::ComboBox&, void);
    DECL_LINK(ChangeAttrClickHdl_Impl, weld::ToggleButton&, void);
    void ChangeAttrHdl_Impl(void const *);

public:

    SvxMeasurePage( vcl::Window* pWindow, const SfxItemSet& rInAttrs );
    SvxMeasurePage(TabPageParent pWindow, const SfxItemSet& rInAttrs);
    virtual ~SvxMeasurePage() override;
    virtual void dispose() override;

diff --git a/cui/source/tabpages/measure.cxx b/cui/source/tabpages/measure.cxx
index 704016d..b46fcdb 100644
--- a/cui/source/tabpages/measure.cxx
+++ b/cui/source/tabpages/measure.cxx
@@ -77,73 +77,63 @@
|*
\************************************************************************/

SvxMeasurePage::SvxMeasurePage( vcl::Window* pWindow, const SfxItemSet& rInAttrs ) :
                SvxTabPage      ( pWindow
                                 ,"DimensionLinesTabPage"
                                 ,"cui/ui/dimensionlinestabpage.ui"
                                 ,rInAttrs ),
        rOutAttrs               ( rInAttrs ),
        aAttrSet                ( *rInAttrs.GetPool() ),
        pView( nullptr ),
        eUnit( MapUnit::Map100thMM ),
        bPositionModified       ( false )
SvxMeasurePage::SvxMeasurePage(TabPageParent pWindow, const SfxItemSet& rInAttrs)
    : SvxTabPage(pWindow, "cui/ui/dimensionlinestabpage.ui", "DimensionLinesTabPage", rInAttrs)
    , rOutAttrs(rInAttrs)
    , aAttrSet(*rInAttrs.GetPool())
    , pView(nullptr)
    , eUnit(MapUnit::Map100thMM)
    , bPositionModified(false)
    , m_aCtlPosition(this)
    , m_xMtrFldLineDist(m_xBuilder->weld_metric_spin_button("MTR_LINE_DIST", FUNIT_MM))
    , m_xMtrFldHelplineOverhang(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE_OVERHANG", FUNIT_MM))
    , m_xMtrFldHelplineDist(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE_DIST", FUNIT_MM))
    , m_xMtrFldHelpline1Len(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE1_LEN", FUNIT_MM))
    , m_xMtrFldHelpline2Len(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE2_LEN", FUNIT_MM))
    , m_xTsbBelowRefEdge(m_xBuilder->weld_check_button("TSB_BELOW_REF_EDGE"))
    , m_xMtrFldDecimalPlaces(m_xBuilder->weld_spin_button("MTR_FLD_DECIMALPLACES"))
    , m_xTsbAutoPosV(m_xBuilder->weld_check_button("TSB_AUTOPOSV"))
    , m_xTsbAutoPosH(m_xBuilder->weld_check_button("TSB_AUTOPOSH"))
    , m_xTsbShowUnit(m_xBuilder->weld_check_button("TSB_SHOW_UNIT"))
    , m_xLbUnit(m_xBuilder->weld_combo_box("LB_UNIT"))
    , m_xTsbParallel(m_xBuilder->weld_check_button("TSB_PARALLEL"))
    , m_xFtAutomatic(m_xBuilder->weld_label("STR_MEASURE_AUTOMATIC"))
    , m_xCtlPosition(new weld::CustomWeld(*m_xBuilder, "CTL_POSITION", m_aCtlPosition))
    , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder, "CTL_PREVIEW", m_aCtlPreview))
{
    get(m_pMtrFldLineDist, "MTR_LINE_DIST");
    get(m_pMtrFldHelplineOverhang, "MTR_FLD_HELPLINE_OVERHANG");
    get(m_pMtrFldHelplineDist, "MTR_FLD_HELPLINE_DIST");
    get(m_pMtrFldHelpline1Len, "MTR_FLD_HELPLINE1_LEN");
    get(m_pMtrFldHelpline2Len, "MTR_FLD_HELPLINE2_LEN");
    get(m_pTsbBelowRefEdge, "TSB_BELOW_REF_EDGE");
    get(m_pMtrFldDecimalPlaces, "MTR_FLD_DECIMALPLACES");

    get(m_pCtlPosition, "CTL_POSITION");
    get(m_pTsbAutoPosV, "TSB_AUTOPOSV");
    get(m_pTsbAutoPosH, "TSB_AUTOPOSH");
    get(m_pTsbShowUnit, "TSB_SHOW_UNIT");
    get(m_pLbUnit, "LB_UNIT");
    get(m_pTsbParallel, "TSB_PARALLEL");

    get(m_pCtlPreview, "CTL_PREVIEW");
    m_pCtlPreview->SetAttributes(rInAttrs);

    get(m_pFtAutomatic,"STR_MEASURE_AUTOMATIC");
    m_aCtlPreview.SetAttributes(rInAttrs);

    FillUnitLB();

    const FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
    SetFieldUnit( *m_pMtrFldLineDist, eFUnit );
    SetFieldUnit( *m_pMtrFldHelplineOverhang, eFUnit );
    SetFieldUnit( *m_pMtrFldHelplineDist, eFUnit );
    SetFieldUnit( *m_pMtrFldHelpline1Len, eFUnit );
    SetFieldUnit( *m_pMtrFldHelpline2Len, eFUnit );
    SetFieldUnit( *m_xMtrFldLineDist, eFUnit );
    SetFieldUnit( *m_xMtrFldHelplineOverhang, eFUnit );
    SetFieldUnit( *m_xMtrFldHelplineDist, eFUnit );
    SetFieldUnit( *m_xMtrFldHelpline1Len, eFUnit );
    SetFieldUnit( *m_xMtrFldHelpline2Len, eFUnit );
    if( eFUnit == FUNIT_MM )
    {
        m_pMtrFldLineDist->SetSpinSize( 50 );
        m_pMtrFldHelplineOverhang->SetSpinSize( 50 );
        m_pMtrFldHelplineDist->SetSpinSize( 50 );
        m_pMtrFldHelpline1Len->SetSpinSize( 50 );
        m_pMtrFldHelpline2Len->SetSpinSize( 50 );
        m_xMtrFldLineDist->set_increments(50, 500, FUNIT_NONE);
        m_xMtrFldHelplineOverhang->set_increments(50, 500, FUNIT_NONE);
        m_xMtrFldHelplineDist->set_increments(50, 500, FUNIT_NONE);
        m_xMtrFldHelpline1Len->set_increments(50, 500, FUNIT_NONE);
        m_xMtrFldHelpline2Len->set_increments(50, 500, FUNIT_NONE);
    }

    m_pTsbAutoPosV->SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
    m_pTsbAutoPosH->SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
    m_xTsbAutoPosV->connect_toggled(LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl));
    m_xTsbAutoPosH->connect_toggled(LINK(this, SvxMeasurePage, ClickAutoPosHdl_Impl));

    // set background and border of iconchoicectrl
    const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
    m_pCtlPreview->SetBackground ( rStyles.GetWindowColor() );
    m_pCtlPreview->SetBorderStyle(WindowBorderStyle::MONO);

    Link<Edit&,void> aLink( LINK( this, SvxMeasurePage, ChangeAttrEditHdl_Impl ) );
    m_pMtrFldLineDist->SetModifyHdl( aLink );
    m_pMtrFldHelplineOverhang->SetModifyHdl( aLink );
    m_pMtrFldHelplineDist->SetModifyHdl( aLink );
    m_pMtrFldHelpline1Len->SetModifyHdl( aLink );
    m_pMtrFldHelpline2Len->SetModifyHdl( aLink );
    m_pMtrFldDecimalPlaces->SetModifyHdl( aLink );
    m_pTsbBelowRefEdge->SetClickHdl( LINK( this, SvxMeasurePage, ChangeAttrClickHdl_Impl ) );
    m_pTsbParallel->SetClickHdl( LINK( this, SvxMeasurePage, ChangeAttrClickHdl_Impl ) );
    m_pTsbShowUnit->SetClickHdl( LINK( this, SvxMeasurePage, ChangeAttrClickHdl_Impl ) );
    m_pLbUnit->SetSelectHdl( LINK( this, SvxMeasurePage, ChangeAttrListBoxHdl_Impl ) );
    Link<weld::MetricSpinButton&,void> aLink(LINK(this, SvxMeasurePage, ChangeAttrEditHdl_Impl));
    m_xMtrFldLineDist->connect_value_changed(aLink);
    m_xMtrFldHelplineOverhang->connect_value_changed(aLink);
    m_xMtrFldHelplineDist->connect_value_changed(aLink);
    m_xMtrFldHelpline1Len->connect_value_changed(aLink);
    m_xMtrFldHelpline2Len->connect_value_changed(aLink);
    m_xMtrFldDecimalPlaces->connect_value_changed(LINK(this, SvxMeasurePage, ChangeAttrSpinHdl_Impl));
    m_xTsbBelowRefEdge->connect_toggled(LINK(this, SvxMeasurePage, ChangeAttrClickHdl_Impl));
    m_xTsbParallel->connect_toggled( LINK( this, SvxMeasurePage, ChangeAttrClickHdl_Impl));
    m_xTsbShowUnit->connect_toggled(LINK(this, SvxMeasurePage, ChangeAttrClickHdl_Impl));
    m_xLbUnit->connect_changed(LINK(this, SvxMeasurePage, ChangeAttrListBoxHdl_Impl));
}

SvxMeasurePage::~SvxMeasurePage()
@@ -153,21 +143,8 @@

void SvxMeasurePage::dispose()
{
    m_pMtrFldLineDist.clear();
    m_pMtrFldHelplineOverhang.clear();
    m_pMtrFldHelplineDist.clear();
    m_pMtrFldHelpline1Len.clear();
    m_pMtrFldHelpline2Len.clear();
    m_pTsbBelowRefEdge.clear();
    m_pMtrFldDecimalPlaces.clear();
    m_pCtlPosition.clear();
    m_pTsbAutoPosV.clear();
    m_pTsbAutoPosH.clear();
    m_pTsbShowUnit.clear();
    m_pLbUnit.clear();
    m_pTsbParallel.clear();
    m_pFtAutomatic.clear();
    m_pCtlPreview.clear();
    m_xCtlPreview.reset();
    m_xCtlPosition.reset();
    SvxTabPage::dispose();
}

@@ -191,13 +168,13 @@
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_pMtrFldLineDist, nValue, eUnit );
        SetMetricValue( *m_xMtrFldLineDist, nValue, eUnit );
    }
    else
    {
        m_pMtrFldLineDist->SetText( OUString() );
        m_xMtrFldLineDist->set_text(OUString());
    }
    m_pMtrFldLineDist->SaveValue();
    m_xMtrFldLineDist->save_value();

    // SdrMeasureHelplineOverhangItem
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG );
@@ -206,13 +183,13 @@
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_pMtrFldHelplineOverhang, nValue, eUnit );
        SetMetricValue( *m_xMtrFldHelplineOverhang, nValue, eUnit );
    }
    else
    {
        m_pMtrFldHelplineOverhang->SetText( OUString() );
        m_xMtrFldHelplineOverhang->set_text(OUString());
    }
    m_pMtrFldHelplineOverhang->SaveValue();
    m_xMtrFldHelplineOverhang->save_value();

    // SdrMeasureHelplineDistItem
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEDIST );
@@ -221,13 +198,13 @@
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_pMtrFldHelplineDist, nValue, eUnit );
        SetMetricValue( *m_xMtrFldHelplineDist, nValue, eUnit );
    }
    else
    {
        m_pMtrFldHelplineDist->SetText( OUString() );
        m_xMtrFldHelplineDist->set_text(OUString());
    }
    m_pMtrFldHelplineDist->SaveValue();
    m_xMtrFldHelplineDist->save_value();

    // SdrMeasureHelpline1LenItem
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE1LEN );
@@ -236,13 +213,13 @@
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_pMtrFldHelpline1Len, nValue, eUnit );
        SetMetricValue( *m_xMtrFldHelpline1Len, nValue, eUnit );
    }
    else
    {
        m_pMtrFldHelpline1Len->SetText( OUString() );
        m_xMtrFldHelpline1Len->set_text(OUString());
    }
    m_pMtrFldHelpline1Len->SaveValue();
    m_xMtrFldHelpline1Len->save_value();

    // SdrMeasureHelpline2LenItem
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE2LEN );
@@ -251,26 +228,25 @@
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_pMtrFldHelpline2Len, nValue, eUnit );
        SetMetricValue( *m_xMtrFldHelpline2Len, nValue, eUnit );
    }
    else
    {
        m_pMtrFldHelpline2Len->SetText( OUString() );
        m_xMtrFldHelpline2Len->set_text(OUString());
    }
    m_pMtrFldHelpline2Len->SaveValue();
    m_xMtrFldHelpline2Len->save_value();

    // SdrMeasureBelowRefEdgeItem
    if( rAttrs->GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SfxItemState::DONTCARE )
    {
        m_pTsbBelowRefEdge->SetState( rAttrs->Get( SDRATTR_MEASUREBELOWREFEDGE ).
        m_xTsbBelowRefEdge->set_state( rAttrs->Get( SDRATTR_MEASUREBELOWREFEDGE ).
                        GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
        m_pTsbBelowRefEdge->EnableTriState( false );
    }
    else
    {
        m_pTsbBelowRefEdge->SetState( TRISTATE_INDET );
        m_xTsbBelowRefEdge->set_state( TRISTATE_INDET );
    }
    m_pTsbBelowRefEdge->SaveValue();
    m_xTsbBelowRefEdge->save_state();

    // SdrMeasureDecimalPlacesItem
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREDECIMALPLACES );
@@ -279,60 +255,58 @@
    if( pItem )
    {
        sal_Int16 nValue = static_cast<const SdrMeasureDecimalPlacesItem*>( pItem )->GetValue();
        m_pMtrFldDecimalPlaces->SetValue( nValue );
        m_xMtrFldDecimalPlaces->set_value(nValue);
    }
    else
    {
        m_pMtrFldDecimalPlaces->SetText( OUString() );
        m_xMtrFldDecimalPlaces->set_text(OUString());
    }
    m_pMtrFldDecimalPlaces->SaveValue();
    m_xMtrFldDecimalPlaces->save_value();

    // SdrMeasureTextRota90Item
    // Attention: negate !
    if( rAttrs->GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SfxItemState::DONTCARE )
    {
        m_pTsbParallel->SetState( rAttrs->Get( SDRATTR_MEASURETEXTROTA90 ).
        m_xTsbParallel->set_state( rAttrs->Get( SDRATTR_MEASURETEXTROTA90 ).
                        GetValue() ? TRISTATE_FALSE : TRISTATE_TRUE );
        m_pTsbParallel->EnableTriState( false );
    }
    else
    {
        m_pTsbParallel->SetState( TRISTATE_INDET );
        m_xTsbParallel->set_state( TRISTATE_INDET );
    }
    m_pTsbParallel->SaveValue();
    m_xTsbParallel->save_state();

    // SdrMeasureShowUnitItem
    if( rAttrs->GetItemState( SDRATTR_MEASURESHOWUNIT ) != SfxItemState::DONTCARE )
    {
        m_pTsbShowUnit->SetState( rAttrs->Get( SDRATTR_MEASURESHOWUNIT ).
        m_xTsbShowUnit->set_state( rAttrs->Get( SDRATTR_MEASURESHOWUNIT ).
                        GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
        m_pTsbShowUnit->EnableTriState( false );
    }
    else
    {
        m_pTsbShowUnit->SetState( TRISTATE_INDET );
        m_xTsbShowUnit->set_state( TRISTATE_INDET );
    }
    m_pTsbShowUnit->SaveValue();
    m_xTsbShowUnit->save_state();

    // SdrMeasureUnitItem
    if( rAttrs->GetItemState( SDRATTR_MEASUREUNIT ) != SfxItemState::DONTCARE )
    {
        long nFieldUnit = static_cast<long>(rAttrs->Get( SDRATTR_MEASUREUNIT ).GetValue());

        for( sal_Int32 i = 0; i < m_pLbUnit->GetEntryCount(); ++i )
        for (sal_Int32 i = 0; i < m_xLbUnit->get_count(); ++i)
        {
            if ( reinterpret_cast<sal_IntPtr>(m_pLbUnit->GetEntryData( i )) == nFieldUnit )
            if (m_xLbUnit->get_id(i).toInt32() == nFieldUnit)
            {
                m_pLbUnit->SelectEntryPos( i );
                m_xLbUnit->set_active(i);
                break;
            }
        }
    }
    else
    {
        m_pLbUnit->SetNoSelection();
        m_xLbUnit->set_active(-1);
    }
    m_pLbUnit->SaveValue();
    m_xLbUnit->save_value();

    // Position
    if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE )
@@ -342,9 +316,6 @@
        {
            if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
            {
                m_pTsbAutoPosV->EnableTriState( false );
                m_pTsbAutoPosH->EnableTriState( false );

                css::drawing::MeasureTextHorzPos eHPos =
                            rAttrs->Get( SDRATTR_MEASURETEXTHPOS ).GetValue();
                RectPoint eRP = RectPoint::MM;
@@ -397,33 +368,33 @@

                if (eHPos == css::drawing::MeasureTextHorzPos_AUTO)
                {
                    m_pTsbAutoPosH->SetState( TRISTATE_TRUE );
                    m_xTsbAutoPosH->set_state( TRISTATE_TRUE );
                    nState = CTL_STATE::NOHORZ;
                }

                if (eVPos == css::drawing::MeasureTextVertPos_AUTO)
                {
                    m_pTsbAutoPosV->SetState( TRISTATE_TRUE );
                    m_xTsbAutoPosV->set_state( TRISTATE_TRUE );
                    nState |= CTL_STATE::NOVERT;
                }

                m_pCtlPosition->SetState( nState );
                m_pCtlPosition->SetActualRP( eRP );
                m_aCtlPosition.SetState(nState);
                m_aCtlPosition.SetActualRP(eRP);
            }
        }
    }
    else
    {
        m_pCtlPosition->Reset();
        m_pTsbAutoPosV->SetState( TRISTATE_INDET );
        m_pTsbAutoPosH->SetState( TRISTATE_INDET );
        m_aCtlPosition.Reset();
        m_xTsbAutoPosV->set_state( TRISTATE_INDET );
        m_xTsbAutoPosH->set_state( TRISTATE_INDET );
    }

    // put the attributes to the preview-control,
    // otherwise the control don't know about
    // the settings of the dialog (#67930)
    ChangeAttrHdl_Impl( m_pTsbShowUnit );
    m_pCtlPreview->SetAttributes( *rAttrs );
    ChangeAttrHdl_Impl(m_xTsbShowUnit.get());
    m_aCtlPreview.SetAttributes(*rAttrs);

    bPositionModified = false;
}
@@ -440,77 +411,77 @@
    sal_Int32    nValue;
    TriState eState;

    if( m_pMtrFldLineDist->IsValueChangedFromSaved() )
    if( m_xMtrFldLineDist->get_value_changed_from_saved() )
    {
        nValue = GetCoreValue( *m_pMtrFldLineDist, eUnit );
        nValue = GetCoreValue( *m_xMtrFldLineDist, eUnit );
        rAttrs->Put( makeSdrMeasureLineDistItem( nValue ) );
        bModified = true;
    }

    if( m_pMtrFldHelplineOverhang->IsValueChangedFromSaved() )
    if( m_xMtrFldHelplineOverhang->get_value_changed_from_saved() )
    {
        nValue = GetCoreValue( *m_pMtrFldHelplineOverhang, eUnit );
        nValue = GetCoreValue( *m_xMtrFldHelplineOverhang, eUnit );
        rAttrs->Put( makeSdrMeasureHelplineOverhangItem( nValue ) );
        bModified = true;
    }

    if( m_pMtrFldHelplineDist->IsValueChangedFromSaved() )
    if( m_xMtrFldHelplineDist->get_value_changed_from_saved() )
    {
        nValue = GetCoreValue( *m_pMtrFldHelplineDist, eUnit );
        nValue = GetCoreValue( *m_xMtrFldHelplineDist, eUnit );
        rAttrs->Put( makeSdrMeasureHelplineDistItem( nValue ) );
        bModified = true;
    }

    if( m_pMtrFldHelpline1Len->IsValueChangedFromSaved() )
    if( m_xMtrFldHelpline1Len->get_value_changed_from_saved() )
    {
        nValue = GetCoreValue( *m_pMtrFldHelpline1Len, eUnit );
        nValue = GetCoreValue( *m_xMtrFldHelpline1Len, eUnit );
        rAttrs->Put( makeSdrMeasureHelpline1LenItem( nValue ) );
        bModified = true;
    }

    if( m_pMtrFldHelpline2Len->IsValueChangedFromSaved() )
    if( m_xMtrFldHelpline2Len->get_value_changed_from_saved() )
    {
        nValue = GetCoreValue( *m_pMtrFldHelpline2Len, eUnit );
        nValue = GetCoreValue( *m_xMtrFldHelpline2Len, eUnit );
        rAttrs->Put( makeSdrMeasureHelpline2LenItem( nValue ) );
        bModified = true;
    }

    eState = m_pTsbBelowRefEdge->GetState();
    if( m_pTsbBelowRefEdge->IsValueChangedFromSaved() )
    eState = m_xTsbBelowRefEdge->get_state();
    if( m_xTsbBelowRefEdge->get_state_changed_from_saved() )
    {
        rAttrs->Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE == eState ) );
        bModified = true;
    }

    if( m_pMtrFldDecimalPlaces->IsValueChangedFromSaved() )
    if( m_xMtrFldDecimalPlaces->get_value_changed_from_saved() )
    {
        nValue = static_cast<sal_Int32>(m_pMtrFldDecimalPlaces->GetValue());
        nValue = m_xMtrFldDecimalPlaces->get_value();
        rAttrs->Put(
            SdrMeasureDecimalPlacesItem(
                sal::static_int_cast< sal_Int16 >( nValue ) ) );
        bModified = true;
    }

    eState = m_pTsbParallel->GetState();
    if( m_pTsbParallel->IsValueChangedFromSaved() )
    eState = m_xTsbParallel->get_state();
    if( m_xTsbParallel->get_state_changed_from_saved() )
    {
        rAttrs->Put( SdrMeasureTextRota90Item( TRISTATE_FALSE == eState ) );
        bModified = true;
    }

    eState = m_pTsbShowUnit->GetState();
    if( m_pTsbShowUnit->IsValueChangedFromSaved() )
    eState = m_xTsbShowUnit->get_state();
    if( m_xTsbShowUnit->get_state_changed_from_saved() )
    {
        rAttrs->Put( SdrYesNoItem(SDRATTR_MEASURESHOWUNIT, TRISTATE_TRUE == eState ) );
        bModified = true;
    }

    sal_Int32 nPos = m_pLbUnit->GetSelectedEntryPos();
    if( m_pLbUnit->IsValueChangedFromSaved() )
    int nPos = m_xLbUnit->get_active();
    if( m_xLbUnit->get_value_changed_from_saved() )
    {
        if( nPos != LISTBOX_ENTRY_NOTFOUND )
        if (nPos != -1)
        {
            sal_uInt16 nFieldUnit = static_cast<sal_uInt16>(reinterpret_cast<sal_IntPtr>(m_pLbUnit->GetEntryData( nPos )));
            sal_uInt16 nFieldUnit = m_xLbUnit->get_id(nPos).toUInt32();
            FieldUnit _eUnit = static_cast<FieldUnit>(nFieldUnit);
            rAttrs->Put( SdrMeasureUnitItem( _eUnit ) );
            bModified = true;
@@ -523,7 +494,7 @@
        css::drawing::MeasureTextVertPos eVPos, eOldVPos;
        css::drawing::MeasureTextHorzPos eHPos, eOldHPos;

        RectPoint eRP = m_pCtlPosition->GetActualRP();
        RectPoint eRP = m_aCtlPosition.GetActualRP();
        switch( eRP )
        {
            default:
@@ -546,10 +517,10 @@
            case RectPoint::RB: eVPos = css::drawing::MeasureTextVertPos_WEST;
                        eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
        }
        if (m_pTsbAutoPosH->GetState() == TRISTATE_TRUE)
        if (m_xTsbAutoPosH->get_state() == TRISTATE_TRUE)
            eHPos = css::drawing::MeasureTextHorzPos_AUTO;

        if (m_pTsbAutoPosV->GetState() == TRISTATE_TRUE)
        if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE)
            eVPos = css::drawing::MeasureTextVertPos_AUTO;

        if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE )
@@ -604,162 +575,169 @@
    // floatingpoint-values' is not clear, but has to be done another way - if needed.
    // Checked on original aw080, is just commented out there, too.

    // m_pCtlPreview->pMeasureObj->SetModel( pView->GetModel() );
    m_pCtlPreview->Invalidate();
    m_aCtlPreview.Invalidate();
}

VclPtr<SfxTabPage> SvxMeasurePage::Create( TabPageParent pWindow,
                                           const SfxItemSet* rAttrs )
VclPtr<SfxTabPage> SvxMeasurePage::Create(TabPageParent pParent,
                                          const SfxItemSet* rAttrs)
{
    return VclPtr<SvxMeasurePage>::Create( pWindow.pParent, *rAttrs );
    return VclPtr<SvxMeasurePage>::Create(pParent, *rAttrs);
}

void SvxMeasurePage::PointChanged( vcl::Window* pWindow, RectPoint /*eRP*/ )
{
    ChangeAttrHdl_Impl( pWindow );
    ChangeAttrHdl_Impl(pWindow);
}

void SvxMeasurePage::PointChanged( weld::DrawingArea*, RectPoint /*eRP*/ )
void SvxMeasurePage::PointChanged(weld::DrawingArea* pDrawingArea, RectPoint /*eRP*/)
{
    ChangeAttrHdl_Impl( m_pCtlPosition );
    ChangeAttrHdl_Impl(pDrawingArea);
}

IMPL_LINK( SvxMeasurePage, ClickAutoPosHdl_Impl, Button*, p, void )
IMPL_LINK( SvxMeasurePage, ClickAutoPosHdl_Impl, weld::ToggleButton&, rBox, void )
{
    if( m_pTsbAutoPosH->GetState() == TRISTATE_TRUE )
    if (m_xTsbAutoPosH->get_state() == TRISTATE_TRUE)
    {
        switch( m_pCtlPosition->GetActualRP() )
        switch( m_aCtlPosition.GetActualRP() )
        {
            case RectPoint::LT:
            case RectPoint::RT:
                m_pCtlPosition->SetActualRP( RectPoint::MT );
                m_aCtlPosition.SetActualRP( RectPoint::MT );
            break;

            case RectPoint::LM:
            case RectPoint::RM:
                m_pCtlPosition->SetActualRP( RectPoint::MM );
                m_aCtlPosition.SetActualRP( RectPoint::MM );
            break;

            case RectPoint::LB:
            case RectPoint::RB:
                m_pCtlPosition->SetActualRP( RectPoint::MB );
                m_aCtlPosition.SetActualRP( RectPoint::MB );
            break;
            default: ;//prevent warning
        }
    }
    if( m_pTsbAutoPosV->GetState() == TRISTATE_TRUE )
    if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE)
    {
        switch( m_pCtlPosition->GetActualRP() )
        switch( m_aCtlPosition.GetActualRP() )
        {
            case RectPoint::LT:
            case RectPoint::LB:
                m_pCtlPosition->SetActualRP( RectPoint::LM );
                m_aCtlPosition.SetActualRP( RectPoint::LM );
            break;

            case RectPoint::MT:
            case RectPoint::MB:
                m_pCtlPosition->SetActualRP( RectPoint::MM );
                m_aCtlPosition.SetActualRP( RectPoint::MM );
            break;

            case RectPoint::RT:
            case RectPoint::RB:
                m_pCtlPosition->SetActualRP( RectPoint::RM );
                m_aCtlPosition.SetActualRP( RectPoint::RM );
            break;
            default: ;//prevent warning
        }
    }
    ChangeAttrHdl_Impl( p );
    ChangeAttrHdl_Impl(&rBox);
}

IMPL_LINK( SvxMeasurePage, ChangeAttrClickHdl_Impl, Button*, p, void )
IMPL_LINK(SvxMeasurePage, ChangeAttrClickHdl_Impl, weld::ToggleButton&, r, void)
{
    ChangeAttrHdl_Impl(p);
    ChangeAttrHdl_Impl(&r);
}
IMPL_LINK( SvxMeasurePage, ChangeAttrListBoxHdl_Impl, ListBox&, rBox, void )

IMPL_LINK(SvxMeasurePage, ChangeAttrListBoxHdl_Impl, weld::ComboBox&, rBox, void)
{
    ChangeAttrHdl_Impl(&rBox);
}
IMPL_LINK( SvxMeasurePage, ChangeAttrEditHdl_Impl, Edit&, rBox, void )

IMPL_LINK(SvxMeasurePage, ChangeAttrEditHdl_Impl, weld::MetricSpinButton&, rBox, void)
{
    ChangeAttrHdl_Impl(&rBox);
}

IMPL_LINK( SvxMeasurePage, ChangeAttrSpinHdl_Impl, weld::SpinButton&, rBox, void )
{
    ChangeAttrHdl_Impl(&rBox);
}

void SvxMeasurePage::ChangeAttrHdl_Impl( void const * p )
{
    if( p == m_pMtrFldLineDist )
    if (p == m_xMtrFldLineDist.get())
    {
        sal_Int32 nValue = GetCoreValue( *m_pMtrFldLineDist, eUnit );
        sal_Int32 nValue = GetCoreValue( *m_xMtrFldLineDist, eUnit );
        aAttrSet.Put( makeSdrMeasureLineDistItem( nValue ) );
    }

    if( p == m_pMtrFldHelplineOverhang )
    if (p == m_xMtrFldHelplineOverhang.get())
    {
        sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelplineOverhang, eUnit );
        sal_Int32 nValue = GetCoreValue( *m_xMtrFldHelplineOverhang, eUnit );
        aAttrSet.Put( makeSdrMeasureHelplineOverhangItem( nValue) );
    }

    if( p == m_pMtrFldHelplineDist )
    if (p == m_xMtrFldHelplineDist.get())
    {
        sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelplineDist, eUnit );
        sal_Int32 nValue = GetCoreValue( *m_xMtrFldHelplineDist, eUnit );
        aAttrSet.Put( makeSdrMeasureHelplineDistItem( nValue) );
    }

    if( p == m_pMtrFldHelpline1Len )
    if (p == m_xMtrFldHelpline1Len.get())
    {
        sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelpline1Len, eUnit );
        sal_Int32 nValue = GetCoreValue( *m_xMtrFldHelpline1Len, eUnit );
        aAttrSet.Put( makeSdrMeasureHelpline1LenItem( nValue ) );
    }

    if( p == m_pMtrFldHelpline2Len )
    if (p == m_xMtrFldHelpline2Len.get())
    {
        sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelpline2Len, eUnit );
        sal_Int32 nValue = GetCoreValue( *m_xMtrFldHelpline2Len, eUnit );
        aAttrSet.Put( makeSdrMeasureHelpline2LenItem( nValue ) );
    }

    if( p == m_pTsbBelowRefEdge )
    if (p == m_xTsbBelowRefEdge.get())
    {
        TriState eState = m_pTsbBelowRefEdge->GetState();
        TriState eState = m_xTsbBelowRefEdge->get_state();
        if( eState != TRISTATE_INDET )
            aAttrSet.Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE == eState ) );
    }

    if( p == m_pMtrFldDecimalPlaces )
    if (p == m_xMtrFldDecimalPlaces.get())
    {
        sal_Int16 nValue = sal::static_int_cast< sal_Int16 >(
            m_pMtrFldDecimalPlaces->GetValue() );
            m_xMtrFldDecimalPlaces->get_value() );
        aAttrSet.Put( SdrMeasureDecimalPlacesItem( nValue ) );
    }

    if( p == m_pTsbParallel )
    if (p == m_xTsbParallel.get())
    {
        TriState eState = m_pTsbParallel->GetState();
        TriState eState = m_xTsbParallel->get_state();
        if( eState != TRISTATE_INDET )
            aAttrSet.Put( SdrMeasureTextRota90Item( TRISTATE_FALSE == eState ) );
    }

    if( p == m_pTsbShowUnit )
    if (p == m_xTsbShowUnit.get())
    {
        TriState eState = m_pTsbShowUnit->GetState();
        TriState eState = m_xTsbShowUnit->get_state();
        if( eState != TRISTATE_INDET )
            aAttrSet.Put( SdrYesNoItem( SDRATTR_MEASURESHOWUNIT, TRISTATE_TRUE == eState ) );
    }

    if( p == m_pLbUnit )
    if (p == m_xLbUnit.get())
    {
        sal_Int32 nPos = m_pLbUnit->GetSelectedEntryPos();
        if( nPos != LISTBOX_ENTRY_NOTFOUND )
        int nPos = m_xLbUnit->get_active();
        if (nPos != -1)
        {
            sal_uInt16 nFieldUnit = static_cast<sal_uInt16>(reinterpret_cast<sal_IntPtr>(m_pLbUnit->GetEntryData( nPos )));
            sal_uInt16 nFieldUnit = m_xLbUnit->get_id(nPos).toUInt32();
            FieldUnit _eUnit = static_cast<FieldUnit>(nFieldUnit);
            aAttrSet.Put( SdrMeasureUnitItem( _eUnit ) );
        }
    }

    if( p == m_pTsbAutoPosV || p == m_pTsbAutoPosH || p == m_pCtlPosition )
    if (p == m_xTsbAutoPosV.get() || p == m_xTsbAutoPosH.get() || p == m_aCtlPosition.GetDrawingArea())
    {
        bPositionModified = true;

        // Position
        RectPoint eRP = m_pCtlPosition->GetActualRP();
        RectPoint eRP = m_aCtlPosition.GetActualRP();
        css::drawing::MeasureTextVertPos eVPos;
        css::drawing::MeasureTextHorzPos eHPos;

@@ -788,27 +766,27 @@

        CTL_STATE nState = CTL_STATE::NONE;

        if (m_pTsbAutoPosH->GetState() == TRISTATE_TRUE)
        if (m_xTsbAutoPosH->get_state() == TRISTATE_TRUE)
        {
            eHPos = css::drawing::MeasureTextHorzPos_AUTO;
            nState = CTL_STATE::NOHORZ;
        }

        if (m_pTsbAutoPosV->GetState() == TRISTATE_TRUE)
        if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE)
        {
            eVPos = css::drawing::MeasureTextVertPos_AUTO;
            nState |= CTL_STATE::NOVERT;
        }

        if( p == m_pTsbAutoPosV || p == m_pTsbAutoPosH )
            m_pCtlPosition->SetState( nState );
        if (p == m_xTsbAutoPosV.get() || p == m_xTsbAutoPosH.get())
            m_aCtlPosition.SetState( nState );

        aAttrSet.Put( SdrMeasureTextVPosItem( eVPos ) );
        aAttrSet.Put( SdrMeasureTextHPosItem( eHPos ) );
    }

    m_pCtlPreview->SetAttributes( aAttrSet );
    m_pCtlPreview->Invalidate();
    m_aCtlPreview.SetAttributes(aAttrSet);
    m_aCtlPreview.Invalidate();
}

void SvxMeasurePage::FillUnitLB()
@@ -816,18 +794,17 @@
    // fill ListBox with metrics

    FieldUnit nUnit = FUNIT_NONE;
    OUString aStrMetric( m_pFtAutomatic->GetText());
    sal_Int32 nPos = m_pLbUnit->InsertEntry( aStrMetric );
    m_pLbUnit->SetEntryData( nPos, reinterpret_cast<void*>(nUnit) );
    OUString aStrMetric(m_xFtAutomatic->get_label());
    m_xLbUnit->append(OUString::number(nUnit), aStrMetric);

    for( sal_uInt32 i = 0; i < SvxFieldUnitTable::Count(); ++i )
    {
        aStrMetric = SvxFieldUnitTable::GetString(i);
        nUnit = SvxFieldUnitTable::GetValue(i);
        nPos = m_pLbUnit->InsertEntry( aStrMetric );
        m_pLbUnit->SetEntryData( nPos, reinterpret_cast<void*>(nUnit) );
        m_xLbUnit->append(OUString::number(nUnit), aStrMetric);
    }
}

void SvxMeasurePage::PageCreated(const SfxAllItemSet& aSet)
{
    const OfaPtrItem* pOfaPtrItem = aSet.GetItem<OfaPtrItem>(SID_OBJECT_LIST, false);
diff --git a/cui/uiconfig/ui/dimensionlinestabpage.ui b/cui/uiconfig/ui/dimensionlinestabpage.ui
index 497ee02..5c4b459 100644
--- a/cui/uiconfig/ui/dimensionlinestabpage.ui
+++ b/cui/uiconfig/ui/dimensionlinestabpage.ui
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
  <requires lib="gtk+" version="3.18"/>
  <requires lib="LibreOffice" version="1.0"/>
  <object class="GtkAdjustment" id="adjustment1">
    <property name="lower">-10</property>
    <property name="upper">10</property>
@@ -14,6 +13,30 @@
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustment3">
    <property name="lower">-10</property>
    <property name="upper">10</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="adjustment4">
    <property name="lower">-10</property>
    <property name="upper">10</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="adjustment5">
    <property name="lower">-10</property>
    <property name="upper">10</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="adjustment6">
    <property name="lower">-10</property>
    <property name="upper">10</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkBox" id="DimensionLinesTabPage">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
@@ -48,11 +71,11 @@
                      <object class="GtkLabel" id="FT_LINE_DIST">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="yalign">0.4699999988079071</property>
                        <property name="label" translatable="yes" context="dimensionlinestabpage|FT_LINE_DIST">Line _distance:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_LINE_DIST:0.00mm</property>
                        <property name="mnemonic_widget">MTR_LINE_DIST</property>
                        <property name="xalign">0</property>
                        <property name="yalign">0.4699999988079071</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
@@ -63,10 +86,10 @@
                      <object class="GtkLabel" id="FT_HELPLINE_OVERHANG">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="dimensionlinestabpage|FT_HELPLINE_OVERHANG">Guide _overhang:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_FLD_HELPLINE_OVERHANG:0.00mm</property>
                        <property name="mnemonic_widget">MTR_FLD_HELPLINE_OVERHANG</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
@@ -77,10 +100,10 @@
                      <object class="GtkLabel" id="FT_HELPLINE_DIST">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="dimensionlinestabpage|FT_HELPLINE_DIST">_Guide distance:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_FLD_HELPLINE_DIST:0.00mm</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
@@ -91,10 +114,10 @@
                      <object class="GtkLabel" id="FT_HELPLINE1_LEN">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="dimensionlinestabpage|FT_HELPLINE1_LEN">_Left guide:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_FLD_HELPLINE1_LEN:0.00mm</property>
                        <property name="mnemonic_widget">MTR_FLD_HELPLINE1_LEN</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
@@ -105,10 +128,10 @@
                      <object class="GtkLabel" id="FT_HELPLINE2_LEN">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="dimensionlinestabpage|FT_HELPLINE2_LEN">_Right guide:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_FLD_HELPLINE2_LEN:0.00mm</property>
                        <property name="mnemonic_widget">MTR_FLD_HELPLINE2_LEN</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
@@ -119,10 +142,10 @@
                      <object class="GtkLabel" id="FT_DECIMALPLACES">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="dimensionlinestabpage|FT_DECIMALPLACES">Decimal _places:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_FLD_DECIMALPLACES:0</property>
                        <property name="mnemonic_widget">MTR_FLD_DECIMALPLACES</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
@@ -148,9 +171,10 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="MTR_LINE_DIST:0.00mm">
                      <object class="GtkSpinButton" id="MTR_LINE_DIST">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustment1</property>
                        <property name="digits">2</property>
                      </object>
@@ -160,10 +184,11 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="MTR_FLD_HELPLINE_OVERHANG:0.00mm">
                      <object class="GtkSpinButton" id="MTR_FLD_HELPLINE_OVERHANG">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="adjustment">adjustment1</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustment3</property>
                        <property name="digits">2</property>
                      </object>
                      <packing>
@@ -175,7 +200,8 @@
                      <object class="GtkSpinButton" id="MTR_FLD_HELPLINE_DIST:0.00mm">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="adjustment">adjustment1</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustment4</property>
                        <property name="digits">2</property>
                      </object>
                      <packing>
@@ -184,10 +210,11 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="MTR_FLD_HELPLINE1_LEN:0.00mm">
                      <object class="GtkSpinButton" id="MTR_FLD_HELPLINE1_LEN">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="adjustment">adjustment1</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustment5</property>
                        <property name="digits">2</property>
                      </object>
                      <packing>
@@ -196,10 +223,11 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="MTR_FLD_HELPLINE2_LEN:0.00mm">
                      <object class="GtkSpinButton" id="MTR_FLD_HELPLINE2_LEN">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="adjustment">adjustment1</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustment6</property>
                        <property name="digits">2</property>
                      </object>
                      <packing>
@@ -208,9 +236,10 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="MTR_FLD_DECIMALPLACES:0">
                      <object class="GtkSpinButton" id="MTR_FLD_DECIMALPLACES">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustment2</property>
                      </object>
                      <packing>
@@ -226,8 +255,8 @@
              <object class="GtkLabel" id="label1">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes" context="dimensionlinestabpage|label1">Line</property>
                <property name="xalign">0</property>
                <attributes>
                  <attribute name="weight" value="bold"/>
                </attributes>
@@ -262,9 +291,9 @@
                      <object class="GtkLabel" id="FT_POSITION">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="dimensionlinestabpage|FT_POSITION">_Text position</property>
                        <property name="use_underline">True</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="expand">False</property>
@@ -284,11 +313,29 @@
                            <property name="orientation">vertical</property>
                            <property name="spacing">6</property>
                            <child>
                              <object class="svxlo-SvxRectCtl" id="CTL_POSITION">
                              <object class="GtkScrolledWindow" id="frameselwin">
                                <property name="visible">True</property>
                                <property name="can_focus">False</property>
                                <property name="can_focus">True</property>
                                <property name="halign">start</property>
                                <property name="valign">center</property>
                                <property name="hscrollbar_policy">never</property>
                                <property name="vscrollbar_policy">never</property>
                                <property name="shadow_type">in</property>
                                <child>
                                  <object class="GtkViewport">
                                    <property name="visible">True</property>
                                    <property name="can_focus">False</property>
                                    <child>
                                      <object class="GtkDrawingArea" id="CTL_POSITION">
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
                                        <property name="halign">start</property>
                                        <property name="valign">center</property>
                                      </object>
                                    </child>
                                  </object>
                                </child>
                              </object>
                              <packing>
                                <property name="expand">False</property>
@@ -374,7 +421,7 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkComboBox" id="LB_UNIT">
                      <object class="GtkComboBoxText" id="LB_UNIT">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="halign">start</property>
@@ -394,8 +441,8 @@
              <object class="GtkLabel" id="label2">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes" context="dimensionlinestabpage|label2">Legend</property>
                <property name="xalign">0</property>
                <attributes>
                  <attribute name="weight" value="bold"/>
                </attributes>
@@ -427,9 +474,24 @@
      </packing>
    </child>
    <child>
      <object class="svxlo-SvxXMeasurePreview" id="CTL_PREVIEW:border">
      <object class="GtkScrolledWindow">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="hscrollbar_policy">never</property>
        <property name="vscrollbar_policy">never</property>
        <property name="shadow_type">in</property>
        <child>
          <object class="GtkViewport">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <child>
              <object class="GtkDrawingArea" id="CTL_PREVIEW">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
              </object>
            </child>
          </object>
        </child>
      </object>
      <packing>
        <property name="expand">False</property>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index e79db66..b1fc5ff 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -230,9 +230,6 @@
    <glade-widget-class title="SvxXLinePreview" name="svxlo-SvxXLinePreview"
                        generic-name="Line Preview Window" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
    <glade-widget-class title="SvxXMeasurePreview" name="svxlo-SvxXMeasurePreview"
                        generic-name="Dimension Line Preview Window" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
    <glade-widget-class title="SvxXConnectionPreview" name="svxlo-SvxXConnectionPreview"
                        generic-name="Connector Line Preview Window" parent="GtkDrawingArea"
                            icon-name="widget-gtk-drawingarea"/>
@@ -344,11 +341,8 @@
    <glade-widget-class title="Assign Fields Control" name="swuilo-SwAssignFieldsControl"
                        generic-name="Assign Fields Control" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
    <glade-widget-class title="Rectangle Control" name="svxlo-SvxRectCtl"
                        generic-name="Rectangle Control" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
    <glade-widget-class title="Emboss Control" name="cuilo-EmbossControl"
                        generic-name="Emboss Control" parent="svxlo-SvxRectCtl"
                        generic-name="Emboss Control" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
    <glade-widget-class title="Frame Direction ListBox" name="svxlo-FrameDirectionListBox"
                        generic-name="FrameDirectionListBox" parent="GtkComboBox"
diff --git a/include/svx/measctrl.hxx b/include/svx/measctrl.hxx
index 4cdbb84..c3d2d43 100644
--- a/include/svx/measctrl.hxx
+++ b/include/svx/measctrl.hxx
@@ -19,7 +19,7 @@
#ifndef INCLUDED_SVX_MEASCTRL_HXX
#define INCLUDED_SVX_MEASCTRL_HXX

#include <vcl/ctrl.hxx>
#include <vcl/customweld.hxx>
#include <svx/svxdllapi.h>
#include <memory>

@@ -27,27 +27,26 @@
class SdrMeasureObj;
class SdrModel;

class SVX_DLLPUBLIC SvxXMeasurePreview : public Control
class SVX_DLLPUBLIC SvxXMeasurePreview : public weld::CustomWidgetController
{
 friend class SvxMeasurePage;

private:
    MapMode m_aMapMode;
    SdrMeasureObj* pMeasureObj;
    std::unique_ptr<SdrModel> pModel;

    void ResizeImpl(const Size& rSize);
public:
    SvxXMeasurePreview(vcl::Window* pParent, WinBits nStyle);
    SvxXMeasurePreview();
    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
    virtual ~SvxXMeasurePreview() override;
    virtual void dispose() override;

    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
    virtual void Resize() override;
    virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
    virtual Size GetOptimalSize() const override;

    void SetAttributes(const SfxItemSet& rInAttrs);

    virtual void DataChanged(const DataChangedEvent& rDCEvt) override;
};

#endif
diff --git a/solenv/sanitizers/ui/cui.suppr b/solenv/sanitizers/ui/cui.suppr
index d2f4bbb..3347146 100644
--- a/solenv/sanitizers/ui/cui.suppr
+++ b/solenv/sanitizers/ui/cui.suppr
@@ -195,7 +195,6 @@
cui/uiconfig/ui/connpooloptions.ui://GtkLabel[@id='driver'] orphan-label
cui/uiconfig/ui/databaselinkdialog.ui://GtkLabel[@id='alttitle'] orphan-label
cui/uiconfig/ui/dimensionlinestabpage.ui://GtkLabel[@id='FT_POSITION'] orphan-label
cui/uiconfig/ui/dimensionlinestabpage.ui://svxlo-SvxRectCtl[@id='CTL_POSITION'] no-labelled-by
cui/uiconfig/ui/dimensionlinestabpage.ui://GtkComboBox[@id='LB_UNIT'] no-labelled-by
cui/uiconfig/ui/dimensionlinestabpage.ui://GtkLabel[@id='STR_MEASURE_AUTOMATIC'] orphan-label
cui/uiconfig/ui/eventassignpage.ui://cuilo-MacroEventListBox[@id='assignments:border'] no-labelled-by
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index ebc6f4b..85df3b8 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -87,8 +87,6 @@
    return LogicToPixel(Size(78, 39), MapMode(MapUnit::MapAppFont));
}

VCL_BUILDER_FACTORY(SvxRectCtl)

SvxRectCtl::~SvxRectCtl()
{
    disposeOnce();
diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx
index 578a49c..87c0c3f 100644
--- a/svx/source/dialog/measctrl.cxx
+++ b/svx/source/dialog/measctrl.cxx
@@ -22,62 +22,56 @@
#include <svx/svdmodel.hxx>
#include <svx/measctrl.hxx>
#include <svx/dlgutil.hxx>
#include <vcl/builderfactory.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <memory>

SvxXMeasurePreview::SvxXMeasurePreview(vcl::Window* pParent, WinBits nStyle)
    : Control(pParent, nStyle)
SvxXMeasurePreview::SvxXMeasurePreview()
    : m_aMapMode(MapUnit::Map100thMM)
{
    SetMapMode(MapMode(MapUnit::Map100thMM));

    // Scale: 1:2
    MapMode aMapMode = GetMapMode();
    aMapMode.SetScaleX(Fraction(1, 2));
    aMapMode.SetScaleY(Fraction(1, 2));
    SetMapMode(aMapMode);
    m_aMapMode.SetScaleX(Fraction(1, 2));
    m_aMapMode.SetScaleY(Fraction(1, 2));
}

    Size aSize = GetOutputSize();
    Point aPt1 = Point(aSize.Width() / 5, static_cast<long>(aSize.Height() / 2));
    Point aPt2 = Point(aSize.Width() * 4 / 5, static_cast<long>(aSize.Height() / 2));
void SvxXMeasurePreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
    CustomWidgetController::SetDrawingArea(pDrawingArea);
    Size aSize(getPreviewStripSize(pDrawingArea->get_ref_device()));
    pDrawingArea->set_size_request(aSize.Width(), aSize.Height());

    pModel.reset(new SdrModel(nullptr, nullptr, true));
    pMeasureObj = new SdrMeasureObj(
        *pModel,
        aPt1,
        aPt2);
    pMeasureObj = new SdrMeasureObj(*pModel, Point(), Point());

    bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
    SetDrawMode(bHighContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);

    ResizeImpl(aSize);
    Invalidate();
}

void SvxXMeasurePreview::Resize()
void SvxXMeasurePreview::ResizeImpl(const Size& rSize)
{
    Control::Resize();
    OutputDevice& rRefDevice = GetDrawingArea()->get_ref_device();
    rRefDevice.Push(PushFlags::MAPMODE);

    Size aSize = GetOutputSize();
    rRefDevice.SetMapMode(m_aMapMode);

    Size aSize = rRefDevice.PixelToLogic(rSize);
    Point aPt1 = Point(aSize.Width() / 5, static_cast<long>(aSize.Height() / 2));
    pMeasureObj->SetPoint(aPt1, 0);
    Point aPt2 = Point(aSize.Width() * 4 / 5, static_cast<long>(aSize.Height() / 2));
    pMeasureObj->SetPoint(aPt2, 1);

    rRefDevice.Pop();
}

VCL_BUILDER_FACTORY_CONSTRUCTOR(SvxXMeasurePreview, 0)

Size SvxXMeasurePreview::GetOptimalSize() const
void SvxXMeasurePreview::Resize()
{
    return getPreviewStripSize(*this);
    CustomWidgetController::Resize();
    ResizeImpl(GetOutputSizePixel());
    Invalidate();
}

SvxXMeasurePreview::~SvxXMeasurePreview()
{
    disposeOnce();
}

void SvxXMeasurePreview::dispose()
{
    // No one is deleting the MeasureObj? This is not only an error but also
    // a memory leak (!). Main problem is that this object is still listening to
    // a StyleSheet of the model which was set. Thus, if You want to keep the object,
@@ -89,12 +83,18 @@
    SdrObject::Free(pTemp);

    pModel.reset();
    Control::dispose();
}

void SvxXMeasurePreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
    rRenderContext.Push(PushFlags::MAPMODE);
    rRenderContext.SetMapMode(m_aMapMode);

    bool bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
    rRenderContext.SetDrawMode(bHighContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
    pMeasureObj->SingleObjectPainter(rRenderContext);

    rRenderContext.Pop();
}

void SvxXMeasurePreview::SetAttributes(const SfxItemSet& rInAttrs)
@@ -112,9 +112,8 @@

    if (bZoomIn || bZoomOut)
    {
        MapMode aMapMode = GetMapMode();
        Fraction aXFrac = aMapMode.GetScaleX();
        Fraction aYFrac = aMapMode.GetScaleY();
        Fraction aXFrac = m_aMapMode.GetScaleX();
        Fraction aYFrac = m_aMapMode.GetScaleY();
        std::unique_ptr<Fraction> pMultFrac;

        if (bZoomIn)
@@ -138,35 +137,26 @@
        if (double(aXFrac) > 0.001 && double(aXFrac) < 1000.0 &&
            double(aYFrac) > 0.001 && double(aYFrac) < 1000.0)
        {
            aMapMode.SetScaleX(aXFrac);
            aMapMode.SetScaleY(aYFrac);
            SetMapMode(aMapMode);
            m_aMapMode.SetScaleX(aXFrac);
            m_aMapMode.SetScaleY(aYFrac);

            Size aOutSize(GetOutputSize());
            OutputDevice& rRefDevice = GetDrawingArea()->get_ref_device();
            rRefDevice.Push(PushFlags::MAPMODE);
            rRefDevice.SetMapMode(m_aMapMode);
            Size aOutSize(rRefDevice.PixelToLogic(GetOutputSizePixel()));
            rRefDevice.Pop();

            Point aPt(aMapMode.GetOrigin());
            Point aPt(m_aMapMode.GetOrigin());
            long nX = long((double(aOutSize.Width()) - (double(aOutSize.Width()) * double(*pMultFrac))) / 2.0 + 0.5);
            long nY = long((double(aOutSize.Height()) - (double(aOutSize.Height()) * double(*pMultFrac))) / 2.0 + 0.5);
            aPt.AdjustX(nX );
            aPt.AdjustY(nY );

            aMapMode.SetOrigin(aPt);
            SetMapMode(aMapMode);
            m_aMapMode.SetOrigin(aPt);

            Invalidate();
        }
    }
}

void SvxXMeasurePreview::DataChanged( const DataChangedEvent& rDCEvt )
{
    Control::DataChanged( rDCEvt );

    if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
    {
        bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
        SetDrawMode(bHighContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
    }
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */